<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Packages extends BaseModel
{
    protected $table = 'packages';

    public function packages_info(){
        return $this->hasMany(PackagesInfo::class, 'packages_id');
    }


    public function from_campus(){
        return $this->belongsTo(Campus::class, 'from_campus_id');
    }

    public function to_campus(){
        return $this->belongsTo(Campus::class, 'to_campus_id');
    }

    public function sender(){
        return $this->belongsTo(Users::class, 'user_id');
    }

    public function delivery(){
        return $this->belongsTo(Staffs::class, 'delivery_id');
    }

    public function dispatch(){
        return $this->belongsTo(Staffs::class, 'dispatch_id');
    }

    public function containers(){
        return $this->belongsTo(Containers::class, 'containers_id');
    }

    public function getStateAttribute($value)
    {
        $array = [
            'Pending pickup' , 'Picked up' , 'Pending transit' , 'In transit' , 'Pending delivery' , 'Delivering' , 'Signed'
        ];
        return $array[$value];
    }
}
